package com.xjy.headfirst.模板方法模式;

/**
 * decription:
 *
 * @author 辛纪元
 * @since 2022-07-14
 */

public abstract class CaffeineBeverage {

    final void preparRecipe(){
        boilWater();
        brew();
        pourInCup();
        boolean hook = hook();
        if (hook){
            addCondiments();
        }
    }

    abstract void brew();

    abstract void addCondiments();

     void boilWater(){
         System.out.println("Boiling water");
     }

     void pourInCup(){
         System.out.println("Pouring into cup");
     }

    /**
     * 钩子方法
     * @return {@link Boolean}
     */
     boolean hook(){
         return true;
     }

}
